﻿using SUNRPA.CONTROLS.IMPL.domain.attrubutes;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;
using SUNRPA.CONTROLS.IMPL.util;
using System.Collections.Concurrent;
namespace SUNRPA.CONTROLS.IMPL.domain.flowItemParam {
    [Serializable]
    [VarFieldName("ExcelDataOut")]
    public class ReadExcelNParam:BaseParam {
        private string excelObject = "{excelObject}";
        //0单元格内容，1、行，2列，3区域，4已使用区域
        private int readRange = 0;
        private string startRow;
        private string startColumn;
        private string endRow;
        private string endColumn;
        private string sheetName;
        private string excelDataOut = "excelData";
        //读取单元格肉眼所见内容，否则1会变成1.0，日期回事日期对象
        private bool readShowsContent = false;
        private bool trimContent = false;

        public string GetTranslateReadRange() {
            switch(this.readRange) {
                case 0:
                    return $"单元格[{startRow},{startColumn}]";
                case 3:
                    return $"起始单元格[{startRow},{startColumn}],结束单元格[{endRow},{endColumn}]的区域";
                case 1:
                    return $"第{startRow}行";
                case 2:
                    return $"第{startColumn}列";
                case 4:
                    return "已使用区域";
                default:
                    return "已使用区域";
            }
        }
         public bool ReadShowsContent { 
            get => readShowsContent; 
            set { 
                readShowsContent = value;
                NotifyPropertyChanged("ReadShowsContent");
            }  
        }

        public bool TrimContent { 
            get => trimContent; 
            set { 
                trimContent = value;
                NotifyPropertyChanged("TrimContent");
            }  
        }

        public int ReadRange {
            get => readRange; 
            set { 
                readRange = value;
                NotifyPropertyChanged("ReadRange");
            }  
        }

        public string ExcelDataOut {
            get => excelDataOut; 
            set { 
                excelDataOut = value;
                NotifyPropertyChanged("ExcelDataOut");
            }  
        }

        public string ExcelObject {
            get => excelObject; 
            set { 
                excelObject = value;
                NotifyPropertyChanged("ExcelObject");
            }  
        }

        public string SheetName {
            get => sheetName; 
            set { 
                sheetName = value;
                NotifyPropertyChanged("SheetName");
            }  
        }
        public string StartRow {
            get => startRow; 
            set { 
                startRow = value;
                NotifyPropertyChanged("StartRow");
            }  
        }

        public string EndRow {
            get => endRow; 
            set { 
                endRow = value;
                NotifyPropertyChanged("EndRow");
            }  
        }

        public string StartColumn {
            get => startColumn; 
            set { 
                startColumn = value;
                NotifyPropertyChanged("StartColumn");
            }  
        }

        public string EndColumn {
            get => endColumn; 
            set { 
                endColumn = value;
                NotifyPropertyChanged("EndColumn");
            }  
        }
        public override void SetLatestVarName(ConcurrentDictionary<string, ConcurrentDictionary<string, RPAVariableDefineWrapper>> globleData) {
            this.excelDataOut = this.GetLatestName(this.excelDataOut, globleData);
        }
    }
}
